<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="${path}/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${path}/static/css/font-awesome.min.css">
    <link rel="stylesheet" href="${path}/static/css/login.css">
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <div><a class="navbar-brand" href="" style="font-size:32px;">平台</a></div>
        </div>
    </div>
</nav>

<div class="container">

    <form  class="form-signin" role="form" id="loginForm">
        <h2 class="form-signin-heading"><i class="glyphicon glyphicon-user"></i> 用户登录</h2>
        <div class="form-group has-success has-feedback">
            <input type="text" class="form-control" id="username" name="username" placeholder="请输入登录账号" autofocus  />
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
        </div>
        <div class="form-group has-success has-feedback">
            <input type="password" class="form-control" id="userpwd" name="userpwd" placeholder="请输入登录密码" style="margin-top:10px;"  />
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        </div>

        <a class="btn btn-lg btn-success btn-block" onclick="return dologin()" > 登录</a>
    </form>
</div>
<script src="${path}/static/jquery/jquery-2.1.1.min.js"></script>
<script src="${path}/static/bootstrap/js/bootstrap.min.js"></script>
<script src="${path}/static/layer/layer.js"></script>
<script>
    function dologin() {

        var nameVal = $("#username").val();
        if(nameVal==null || nameVal==""){
            layer.msg("用户名不能为空", {time:1000, icon:5, shift:6}, function(){})
            return;
        }
        var pwdVal = $("#userpwd").val();
        if (pwdVal==null || pwdVal==""){
            layer.msg("密码不能为空", {time:1000, icon:5, shift:6}, function(){})
        }
        $.ajax({
            url:"${path}/loginDo",
            method:"post",
            data:$("#loginForm").serialize(),
            error:function (ree) {
                alert("失败")
            },
            success:function (obj) {
                if (obj.result){
                    layer.msg("登陆成功", {time:1000, icon:6, shift:2}, function(){
                        window.location.href = "${path}/main";
                    })
                }else {
                    layer.msg("用户名密码错误", {time:1000, icon:5, shift:6}, function(){})
                }
            }
        })

    }
</script>
</body>
</html>